public class Structure extends Tileable {
	public int clockStep;
	public int offensive;
	public int defensive;
	public int armor;
	public int production;
	public int health;
	public int rawUpkeep;
	public int upkeep;
	public Player player;
	public int cityID;
	public int powerDelay = 0;
	public String mode;
	public RTSQueue<Character> productionQueue; // to be changed to Queue
	public RTSQueue<int[]> commandQueue; // to be changed to Queue

	public Structure(int _id, Player player) {
		this.ID = _id;
		this.type = 's';
		this.player = player;
		this.offensive = 20;
		this.defensive = 10;
		this.armor = 10;
		this.production = 1000;
		this.health = 1000;
		this.rawUpkeep = 100;
		this.upkeep = rawUpkeep;
		this.mode = "STANDBY";
		this.productionQueue = new RTSQueue<Character>();
		this.commandQueue = new RTSQueue<int[]>();
	}

	public void delCommands() {
		this.mode = "STANDBY";
		commandQueue.clear();
	}

	public int[] getStatus() {
		int[] status = new int[10];
		status[0] = this.ID;
		status[1] = this.type;
		status[2] = this.offensive;
		status[3] = this.defensive;
		status[4] = this.armor;
		status[5] = this.production;
		status[6] = this.health;
		status[7] = this.upkeep;
		status[8] = this.player.getID();
		status[9] = this.cityID;
		return status;
	}

	public int getOffensive() {
		return this.offensive;
	}

	public int getDefensive() {
		return this.defensive;
	}

	public int getArmor() {
		return this.armor;
	}

	public int getMovement() {
		return this.production;
	}

	public int getHealth() {
		return this.health;
	}

	public int getUpkeep() {
		return this.upkeep;
	}

	public int getPlayerID() {
		return this.player.getID();
	}

	public int getCityID() {
		return this.cityID;
	}

	public String[] gettxtStatus() {
		String[] status = new String[8];
		status[0] = this.getTypeName(this.type);
		status[1] = "ID: " + this.ID;
		status[2] = "DMG: " + this.offensive;
		status[3] = "DEF: " + this.defensive;
		status[4] = "Armor: " + this.armor;
		status[5] = "Prod.: " + this.production;
		status[6] = "HP: " + this.health;
		status[7] = this.mode;
		return status;
	}

	public String[] gettxtCommands() {
		String[] commands = { "Decommission", "Power down", "Power up",
				"Cancel orders" };
		return commands;
	}
	
	public String getCommandTxt() {
		if (commandQueue.getSize() > 0) {
			int[] command;
			command = commandQueue.peek();
			switch (command[0]) {
			default:
				return "Idle";
			}
		} else {
			return "Idle";
		}
	}

	public void destroy() {
		this.health = 0;
	}

	public void powerDown() {
		if (this.mode != "SLEEP") {
			this.powerDelay = 10;
		}
		this.mode = "SLEEP";
		this.upkeep = rawUpkeep / 4;
	}

	public void powerUp() {
		if (this.mode == "SLEEP") {
			this.mode = "POWERING UP";
		} else {
			this.mode = "STANDBY";
		}
		this.upkeep = rawUpkeep * 3 / 4;
	}

	public void createUnit(Player p, Map m, int i) {

	}

	public void cancelOrder() {
		while (!this.commandQueue.isEmpty()) {
			this.commandQueue.pop();
		}
	}

}
